<html >

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <title>寻ta千百度</title>
    <!-- Font Awesome -->
    <link rel="stylesheet" href="/css/all.css">
    <!-- Bootstrap core CSS -->
    <link href="/background/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="/layui/css/layui.css">
    <link href="/background/css/style.min.css" rel="stylesheet">


    <style>
        .pagination>.active>a, .pagination>.active>a:focus, .pagination>.active>a:hover, .pagination>.active>span, .pagination>.active>span:focus, .pagination>.active>span:hover {
            z-index: 3;
            color: #fff;
            cursor: default;
            background-color: #337ab7;
            border-color: #337ab7;
        }
        .pagination>li>a, .pagination>li>span {
            position: relative;
            float: left;
            padding: 6px 12px;
            margin-left: -1px;
            line-height: 1.42857143;
            color: #337ab7;
            text-decoration: none;
            background-color: #fff;
            border: 1px solid #ddd;
        }
        img{

        }
        .table>tbody>tr>td{
            border:0px;
        }
        th{
            font-weight: normal;
        }
        .navbar-collapse{
            background: white;
        }
        .form-control{
            margin-right: 20px;
        }



        .map-container{
            overflow:hidden;
            padding-bottom:56.25%;
            position:relative;
            height:0;
        }
        .map-container iframe{
            left:0;
            top:0;
            height:100%;
            width:100%;
            position:absolute;
        }



    </style>
</head>

<body class="grey lighten-3">



<!--Main Navigation-->
<header>


    <!-- 导航栏 -->
    <nav class="navbar fixed-top navbar-expand-lg navbar-light white scrolling-navbar">
        <div class="container-fluid">

            <!-- Brand -->


            <!-- Collapse -->
            <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent"
                    aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
            </button>

            <!-- Links -->
            <div class="collapse navbar-collapse" id="navbarSupportedContent">

                <!-- Left -->
                <ul class="navbar-nav mr-auto">
                    <li class="nav-item active">
                        <span style="display: block;margin-top: 8px">${admin.name}</span>
                    </li>

                    <li class="nav-item">
                        <a class="nav-link waves-effect" href="/admin/logout">退出</a>
                    </li>

                </ul>


            </div>

        </div>
    </nav>
    <!-- Navbar -->

    <!-- 侧边栏 -->
    <div class="sidebar-fixed position-fixed" >

        <a class="navbar-brand waves-effect" href="#" target="_blank" style="margin-top: 20px;">
            <strong class="blue-text" style="font-size:38px">寻ta千百度</strong>
        </a>


        <!--        <img src="img/logo3.png"  width="220px" height="80px" style="margin-top: 20px;margin-bottom: 20px">-->


        <div class="list-group list-group-flush" style="margin-top: 80px">
            <a href="/admin/index" class="list-group-item waves-effect list-group-item-action">
                <img src="https://s1.ax1x.com/2020/09/24/0St5rV.png" width="25px" height="25px" style="margin-right: 20px"> 管理员表
            </a>
            <a href="/backstage/user" class="list-group-item active list-group-item-action waves-effect">
                <img src="https://s1.ax1x.com/2020/09/24/0SYh7D.png" width="25px" height="25px" style="margin-right: 20px"> 用户表
            </a>
            <a href="/backstage/goods" class="list-group-item list-group-item-action waves-effect">
                <img src="/img/商品.png" width="25px" height="25px" style="margin-right: 20px"> 物品表</a>
            <a href="/backstage/thanks" class="list-group-item list-group-item-action waves-effect">
                <img src="/img/留言.png" width="25px" height="25px" style="margin-right: 20px">公众留言表</a>
            <a href="/backstage/notices" class="list-group-item list-group-item-action waves-effect">
                <img src="/img/公告.png" width="25px" height="25px" style="margin-right: 20px">公告</a>
        </div>

    </div>
    <!-- Sidebar -->

</header>
<!--Main Navigation-->

<!--Main layout-->
<main class="pt-5 mx-lg-5">
    <div class="container-fluid mt-5">

        <!-- 搜索框 -->
        <div class="card mb-4 wow fadeIn">

            <!--Card content-->
            <div class="card-body d-sm-flex justify-content-between">

                <h4 class="mb-2 mb-sm-0 pt-1">
                    <span style="font-size: 30px">用户表</span>
                </h4>

                <button class="btn btn-primary"  onclick="getAllUsers()">显示全部用户</button>

                <form class="d-flex justify-content-center" action="/backstage/findUserByName">
                    <!-- Default input -->
                    <input type="username" placeholder="你要查询的用户名" aria-label="Search" class="form-control" id="search">
                    <button class="btn btn-primary btn-sm my-0 p" type="submit">
                        <img src="https://s1.ax1x.com/2020/09/24/0SJk2q.png" width="25px" height="25px">
                    </button>
                </form>

            </div>

        </div>

        <!-- 用户表体 -->
        <div class="card mb-4 wow fadeIn" >


            <table class="table table-hover" id="table1"  >
                <thead class="blue-grey lighten-4">
                <tr style="background: #007bff">
                    <th style="color: white">ID</th>
                    <th style="color: white">用户名</th>
                    <th style="color: white">创建时间</th>
                    <th style="color: white">电话号码</th>
                    <th style="color: white">操作</th>
                </tr>
                    <tr>
                        <td>${user.id}</td>
                        <td>${user.username}</td>
                        <td>${user.date?string("yyyy-MM-dd HH:mm:ss")}</td>
                        <td>${user.tel}</td>
                        <td> <a onclick="getId(${user.id})"> <img src="https://s1.ax1x.com/2020/09/24/0S8f0g.png" style="width: 30px;height: 30px;margin-right: 20px"></a>
                        </td>

                    </tr>
                </thead>
                <!-- Table head -->

                <!-- Table body -->
                <tbody id="tbody">
                </tbody>
            </table>
        </div>
    </div>
</main>


<!-- 模态框（Modal） -->


<script type="text/javascript" src="/background/js/jquery-3.5.1.js"></script>
<!-- Bootstrap tooltips -->
<script type="text/javascript" src="/background/js/popper.min.js"></script>
<!-- Bootstrap core JavaScript -->
<script type="text/javascript" src="/background/js/bootstrap.min.js"></script>
<!--  &lt;!&ndash; MDB core JavaScript &ndash;&gt;-->
<script src="/background/js/pagination.js"></script>
<script src="/layui/layui.js"></script>
<!-- Initializations -->
<script type="text/javascript">

    function getAllUsers() {
        window.location.href="/backstage/user";
    }

    function getId(userId){
        var data={"id":userId};
        layui.use('layer', function(){
            var layer = layui.layer;
            layer.open({
                type:'0',
                title: '寻ta',
                btn:['确认','取消']
                ,content: '确认删除吗？',
                yes: function(index, layero){
                    $.post("/deleteUser",data,function (data) {
                        if(data=='true') {
                            alert("删除成功");
                            window.location.href="/backstage/user"
                        }
                        else alert("删除失败");
                    });
                    layer.close(index);
                }
            });
        });
    }
    function doEdit(id) {

        $.post("/queryAdmin",{"id":id},function (data) {
            console.log(data);
            $("#myModal_1").modal();
            $("#txt_ID1").val(id);
            $("#txt_name1").val(data.name);
            $("#txt_password1").val(data.password);
            $("#txt_control").val(data.type);
        },"json");

    }


    function updateAdmin() {
        var da={"id":$("#txt_ID1").val(),"name":$("#txt_name1").val(),"password":$("#txt_password1").val(),"type":$("#txt_control").val()};
        $.post("/updateAdmin",da,function (data) {
            layui.use('layer', function(){
                var layer = layui.layer;
                if(data=='true') {
                    layer.alert('修改成功');
                    setTimeout(function () {
                        window.parent.location.href="/admin/index";
                    },1500)
                }
                else alert("修改失败");
            });

        });
    }
</script>




</body>

</html>
